/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aprendizajePorRefuerzo.interfaz;

import java.awt.Color;

/**
 *
 * @author Fernando Sorzana
 */
public class PnlCasilla extends javax.swing.JPanel {

    private EstadoCasilla estadoCasilla;
    
    private int fila;
    
    private int columna;
    
    private PnlGrilla padre;
    
    /**
     * Creates new form PnlCasilla
     */
    public PnlCasilla() {
        initComponents();
    }

    public EstadoCasilla getEstadoCasilla() {
        return estadoCasilla;
    }

    public void setEstadoCasilla(EstadoCasilla estadoCasilla) {
        this.estadoCasilla = estadoCasilla;
        this.setBackground(estadoCasilla.color);
        this.setTexto(estadoCasilla.texto);
    }

    public int getFila() {
        return fila;
    }

    public void setFila(int fila) {
        this.fila = fila;
    }

    public int getColumna() {
        return columna;
    }

    public void setColumna(int columna) {
        this.columna = columna;
    }
    
    public String getTexto() {
        return lblCasilla.getText();
    }
    
    public void setTexto(String texto) {
        lblCasilla.setText(texto);
    }
    
    public Color getColor(){
        return getBackground();
    }
    
    public void setColor(Color color) {
        setBackground(color);
    }

    public PnlGrilla getPadre() {
        return padre;
    }

    public void setPadre(PnlGrilla padre) {
        this.padre = padre;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblCasilla = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));
        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                formMouseClicked(evt);
            }
        });

        lblCasilla.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        lblCasilla.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblCasilla, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblCasilla, javax.swing.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
        padre.click(this);
    }//GEN-LAST:event_formMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel lblCasilla;
    // End of variables declaration//GEN-END:variables

    public enum EstadoCasilla {
        FINAL("G", Color.WHITE),
        INICIAL("S", Color.WHITE),
        INTRANSITABLE("", Color.BLACK),
        NORMAL("",Color.WHITE);
        
        private String texto;
        
        private Color color;
        
        private EstadoCasilla(String texto, Color color){
            this.texto = texto;
            this.color = color;
        }
    }
    
}
